Skip to content

fix(setup): handle --help/-h before launching setup wizard#592

Merged
jpoehnelt merged 5 commits intomainfrom
fix/setup-help-flag
Mar 23, 2026
Merged

fix(setup): handle --help/-h before launching setup wizard#592
jpoehnelt merged 5 commits intomainfrom
fix/setup-help-flag

Conversation

@jpoehnelt
Copy link
Member

Summary

Handle --help/-h in gws auth setup before launching the setup wizard. Previously, running gws auth setup --help would start the full interactive setup flow (which requires gcloud), confusing users who just wanted usage information.

Fixes #280

Changes

  • Check for --help/-h at the top of run_setup(), before parse_setup_args() and wizard initialization
  • Print usage to stdout (consistent with gws auth --help)
  • Return Ok(()) immediately — no gcloud dependency

Checklist

  • My code follows the AGENTS.md guidelines
  • I have run cargo fmt --all
  • I have run cargo clippy -- -D warnings and resolved all warnings
  • All 750 tests pass
  • I have provided a Changeset file

Check for --help/-h at the top of run_setup() before any work that
requires gcloud. Previously, running 'gws auth setup --help' would
launch the full setup flow.

Fixes #280
@changeset-bot
Copy link

changeset-bot bot commented Mar 23, 2026

🦋 Changeset detected

Latest commit: aa5cf5d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@googleworkspace/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the user experience for the gws auth setup command by implementing an early check for help flags. Previously, invoking gws auth setup with --help or -h would initiate the interactive setup wizard, potentially leading to unintended gcloud operations. The update ensures that usage information is displayed promptly and correctly, streamlining the command-line interaction and preventing confusion.

Highlights

  • Early help flag handling: The gws auth setup command now processes --help or -h flags immediately, preventing the interactive setup wizard from launching when users only seek usage information.
  • Improved user experience: This change avoids accidental project creation or unnecessary gcloud dependency checks for users who simply want to view command options.
  • Output consistency: Help output is now directed to stdout, aligning with the behavior of gws auth --help.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Generative AI Prohibited Use Policy, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@googleworkspace-bot googleworkspace-bot added the cla: yes This human has signed the Contributor License Agreement. label Mar 23, 2026
@codecov
Copy link

codecov bot commented Mar 23, 2026

Codecov Report

❌ Patch coverage is 90.19608% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.02%. Comparing base (d679401) to head (aa5cf5d).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/setup.rs 90.19% 5 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #592   +/-   ##
=======================================
  Coverage   69.02%   69.02%           
=======================================
  Files          42       42           
  Lines       19298    19311   +13     
=======================================
+ Hits        13321    13330    +9     
- Misses       5977     5981    +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces early handling for --help and -h flags in the gws auth setup command. This prevents the setup wizard from launching and potentially creating projects when users only intend to view usage information. A review comment suggests an improvement: defining the usage string as a const to enhance maintainability and readability, as hardcoding it directly in the println! macro could lead to inconsistencies if command options change.

@github-actions github-actions bot added the gemini: reviewed Gemini Code Assist has reviewed the latest changes label Mar 23, 2026
@github-actions github-actions bot removed the gemini: reviewed Gemini Code Assist has reviewed the latest changes label Mar 23, 2026
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses an issue where the gws auth setup command would initiate the setup wizard even when users requested help via --help or -h. The change introduces an early exit mechanism that prints usage information and prevents accidental project creation. The review suggests an improvement opportunity to refactor the argument parsing to use a library like clap for enhanced robustness and maintainability, as the current manual parsing and hardcoded usage string could become fragile with future argument changes.

@github-actions github-actions bot added the gemini: reviewed Gemini Code Assist has reviewed the latest changes label Mar 23, 2026
Use clap::Command for gws auth setup argument parsing instead of manual
while-loop parser. This gives us:
- Automatic --help/-h handling (no manual check needed)
- Proper error messages for unknown flags
- Consistent with other clap usage in the codebase
- Help text stays in sync with actual arguments
@github-actions github-actions bot removed the gemini: reviewed Gemini Code Assist has reviewed the latest changes label Mar 23, 2026
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the command-line argument parsing for gws auth setup to use the clap crate, replacing the manual argument parsing logic. This change aims to correctly handle --help and --version flags, preventing the setup wizard from launching when users only request usage information. The parse_setup_args function now returns a Result to indicate successful parsing or an early exit handled by clap. However, a review comment points out a flaw where all clap parsing errors, including invalid arguments, are currently treated as clean exits, resulting in a success exit code (0) instead of an error. The reviewer suggests distinguishing between clean exits (for help/version) and actual validation errors by modifying the return type of parse_setup_args and adjusting its error handling, along with corresponding updates to run_setup and the tests.

@github-actions github-actions bot added the gemini: reviewed Gemini Code Assist has reviewed the latest changes label Mar 23, 2026
Change parse_setup_args return type from Result<SetupOptions, ()> to
Result<Option<SetupOptions>, GwsError> so that:
- Ok(Some(opts)) = successful parse
- Ok(None) = --help/--version displayed (clean exit, code 0)
- Err(GwsError) = invalid flags (error exit, non-zero code)
@github-actions github-actions bot removed the gemini: reviewed Gemini Code Assist has reviewed the latest changes label Mar 23, 2026
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the argument parsing for gws auth setup to use the clap crate. This change ensures that --help and -h flags are handled correctly, preventing the setup wizard from launching when users only request usage information. The parse_setup_args function now returns a Result<Option<SetupOptions>, GwsError>, allowing for clean exits when help is displayed and proper error handling for invalid arguments. Tests have been updated and expanded to cover these new behaviors. A review comment suggests handling the result of e.print() to prevent silent failures if printing help messages encounters an io::Error.

@github-actions github-actions bot added the gemini: reviewed Gemini Code Assist has reviewed the latest changes label Mar 23, 2026
@github-actions github-actions bot removed the gemini: reviewed Gemini Code Assist has reviewed the latest changes label Mar 23, 2026
@googleworkspace-bot
Copy link
Collaborator

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the argument parsing for the gws auth setup command to use the clap crate. This change improves argument handling, particularly for --help and unknown arguments, preventing accidental project creation when users only intend to view usage information. The parse_setup_args function now returns a Result<Option<SetupOptions>, GwsError>, allowing for clean exits when help is displayed and proper error handling for invalid arguments. Corresponding updates were made to run_setup and several unit tests, with new tests added to cover the clap-based behavior and an old test removed as it's no longer applicable. I have no feedback to provide.

@github-actions github-actions bot added the gemini: reviewed Gemini Code Assist has reviewed the latest changes label Mar 23, 2026
@jpoehnelt jpoehnelt merged commit d341de2 into main Mar 23, 2026
33 of 34 checks passed
@jpoehnelt jpoehnelt deleted the fix/setup-help-flag branch March 23, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: auth cla: yes This human has signed the Contributor License Agreement. gemini: reviewed Gemini Code Assist has reviewed the latest changes

Projects

None yet

3 participants